/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.report.accounting;

import java.util.List;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import src.domain.gl.Gledger;

/**
 *
 * @author Lalugina
 */
public class RptGledgerDS implements JRDataSource{
    private int index = -1;
    private List<Gledger> gledgers;

    public RptGledgerDS(List<Gledger> gledgers) {
        super();
        this.gledgers = gledgers;
    }

    @Override
    public boolean next() throws JRException {
        index++;
        return (index < gledgers.size());
    }

    @Override
    public Object getFieldValue(JRField jrf) throws JRException {
        Object value = null;

	String fieldName = jrf.getName();
        switch (fieldName) {
            case "jvDate": value = gledgers.get(index).getJvDate(); break;
            case "jvNo": value = gledgers.get(index).getJvNO(); break;
            case "deskripsi": value = gledgers.get(index).getDescription(); break;
            case "debit": value = gledgers.get(index).getDebet(); break;
            case "credit": value = gledgers.get(index).getCredit(); break;
            case "saldo": value = gledgers.get(index).getSaldo(); break;
        }
	return value;
    }
    
}
